<template>
	<view class="logo-box" :style="{'--color':vuex_config.themeColor1}">
		<view class="img-box" v-for="(item,index) in imgUrlList" :key="index">
			<image class="img" :src="item" mode=""></image>
			<view @click="selectIndex(index)" class="sign_del iconfont iconfont-e724"></view>
		</view>
		<view class="upload" @click="goupLoad" v-if="!imgUrlList[0] || inputType == 1">
			<u-icon class="upload_icon" name="plus"></u-icon>
		</view>
	</view>
</template>

<script>
	import {
		uploadImage
	} from '@/utils/upload.js';
	export default {
		props: {
			inputType: {
				type: [String, Number],
				default: 0,
			}, // 1多选
			value: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				imgUrlList: []
			};
		},
		mounted() {},

		methods: {
			goupLoad() {
				uploadImage({
					count: this.inputType == 1 ? 9 : 1,
					sizeType:['compressed'],
					size: 10,
				}).then(list => {
					if (this.inputType == 1) {
						this.imgUrlList = this.imgUrlList.concat(list)
					} else {
						this.imgUrlList = list
					}
					this.$emit('input', this.imgUrlList.join(','))
				});
			},
			selectIndex(index) {
				this.imgUrlList.splice(index, 1)
				this.$emit('input', this.imgUrlList.join(','))
			}
		}
	};
</script>

<style scoped lang="scss">
	.logo-box {
		display: flex;
		flex-wrap: wrap;
		padding: 0 28rpx 30rpx 0;
		align-items: center;
	}

	.upload {
		background-color: #f5f5f5;
		width: 180rpx;
		height: 180rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 10rpx;
	}

	.upload_icon {
		color: #999;
		font-size: 80rpx;
	}

	.img-box {
		width: 180rpx;
		height: 180rpx;
		border-radius: 10rpx;
		overflow: hidden;
		position: relative;
		margin-right: 30rpx;
		margin-bottom: 20rpx;

		.sign_del {
			position: absolute;
			right: 4rpx;
			top: 4rpx;
			font-size: 46rpx;
			color: var(--color);
			padding: 6rpx;
		}

		.img {
			width: 100%;
			height: 100%;
		}
	}
</style>
